//
// Copyright 2022 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@use 'sass:map';
@use '@material/theme/theme';
@use '@material/theme/keys';
@use '@material/tokens/resolvers';
@use './select-theme';
@use './select-shared-theme';

$_light-theme: (
  menu-cascading-menu-indicator-icon-color: null,
  menu-cascading-menu-indicator-icon-size: null,
  menu-container-color: null,
  menu-container-elevation: null,
  menu-container-shadow-color: null,
  menu-container-shape: null,
  menu-container-surface-tint-layer-color: null,
  menu-divider-color: null,
  menu-divider-height: null,
  menu-list-item-container-height: null,
  menu-list-item-focus-state-layer-color: null,
  menu-list-item-focus-state-layer-opacity: null,
  menu-list-item-hover-state-layer-color: null,
  menu-list-item-hover-state-layer-opacity: null,
  menu-list-item-label-text-color: null,
  menu-list-item-label-text-font: null,
  menu-list-item-label-text-line-height: null,
  menu-list-item-label-text-size: null,
  menu-list-item-label-text-tracking: null,
  menu-list-item-label-text-type: null,
  menu-list-item-label-text-weight: null,
  menu-list-item-pressed-state-layer-color: null,
  menu-list-item-pressed-state-layer-opacity: null,
  menu-list-item-selected-container-color: null,
  menu-list-item-with-leading-icon-leading-icon-color: null,
  menu-list-item-with-leading-icon-leading-icon-size: null,
  menu-list-item-with-trailing-icon-trailing-icon-color: null,
  menu-list-item-with-trailing-icon-trailing-icon-size: null,
  text-field-active-indicator-color: null,
  text-field-active-indicator-height: null,
  text-field-caret-color: null,
  text-field-container-color: null,
  text-field-container-height: null,
  text-field-container-shape: null,
  text-field-disabled-active-indicator-color: null,
  text-field-disabled-active-indicator-height: null,
  text-field-disabled-active-indicator-opacity: null,
  text-field-disabled-container-color: null,
  text-field-disabled-container-opacity: null,
  text-field-disabled-input-text-color: null,
  text-field-disabled-input-text-opacity: null,
  text-field-disabled-label-text-color: null,
  text-field-disabled-label-text-opacity: null,
  text-field-disabled-leading-icon-color: null,
  text-field-disabled-leading-icon-opacity: null,
  text-field-disabled-supporting-text-color: null,
  text-field-disabled-supporting-text-opacity: null,
  text-field-disabled-trailing-icon-color: null,
  text-field-disabled-trailing-icon-opacity: null,
  text-field-error-active-indicator-color: null,
  text-field-error-caret-color: null,
  text-field-error-focus-active-indicator-color: null,
  text-field-error-focus-caret-color: null,
  text-field-error-focus-input-text-color: null,
  text-field-error-focus-label-text-color: null,
  text-field-error-focus-leading-icon-color: null,
  text-field-error-focus-supporting-text-color: null,
  text-field-error-focus-trailing-icon-color: null,
  text-field-error-hover-active-indicator-color: null,
  text-field-error-hover-caret-color: null,
  text-field-error-hover-input-text-color: null,
  text-field-error-hover-label-text-color: null,
  text-field-error-hover-leading-icon-color: null,
  text-field-error-hover-state-layer-color: null,
  text-field-error-hover-state-layer-opacity: null,
  text-field-error-hover-supporting-text-color: null,
  text-field-error-hover-trailing-icon-color: null,
  text-field-error-input-text-color: null,
  text-field-error-label-text-color: null,
  text-field-error-leading-icon-color: null,
  text-field-error-supporting-text-color: null,
  text-field-error-trailing-icon-color: null,
  text-field-focus-active-indicator-color: null,
  text-field-focus-active-indicator-height: null,
  text-field-focus-caret-color: null,
  text-field-focus-input-text-color: null,
  text-field-focus-label-text-color: null,
  text-field-focus-leading-icon-color: null,
  text-field-focus-supporting-text-color: null,
  text-field-focus-trailing-icon-color: null,
  text-field-hover-active-indicator-color: null,
  text-field-hover-active-indicator-height: null,
  text-field-hover-caret-color: null,
  text-field-hover-input-text-color: null,
  text-field-hover-label-text-color: null,
  text-field-hover-leading-icon-color: null,
  text-field-hover-state-layer-color: null,
  text-field-hover-state-layer-opacity: null,
  text-field-hover-supporting-text-color: null,
  text-field-hover-trailing-icon-color: null,
  text-field-input-text-color: null,
  text-field-input-text-font: null,
  text-field-input-text-line-height: null,
  text-field-input-text-size: null,
  text-field-input-text-tracking: null,
  text-field-input-text-type: null,
  text-field-input-text-weight: null,
  text-field-label-text-color: null,
  text-field-label-text-font: null,
  text-field-label-text-line-height: null,
  text-field-label-text-populated-line-height: null,
  text-field-label-text-populated-size: null,
  text-field-label-text-size: null,
  text-field-label-text-tracking: null,
  text-field-label-text-type: null,
  text-field-label-text-weight: null,
  text-field-leading-icon-color: null,
  text-field-leading-icon-size: null,
  text-field-supporting-text-color: null,
  text-field-supporting-text-font: null,
  text-field-supporting-text-line-height: null,
  text-field-supporting-text-size: null,
  text-field-supporting-text-tracking: null,
  text-field-supporting-text-type: null,
  text-field-supporting-text-weight: null,
  text-field-trailing-icon-color: null,
  text-field-trailing-icon-size: null,
);

$custom-property-prefix: 'filled-select';

@mixin theme($theme, $resolvers: resolvers.$material) {
  @include theme.validate-theme($_light-theme, $theme);
  $theme: select-shared-theme.resolve-theme($theme, $resolvers);
  @include keys.declare-custom-properties($theme, $custom-property-prefix);
}

@mixin theme-styles($theme, $resolvers: resolvers.$material) {
  @include theme.validate-theme-styles($_light-theme, $theme);
  $theme: select-shared-theme.resolve-theme($theme, $resolvers);
  $theme: keys.create-theme-properties(
    $theme,
    $prefix: $custom-property-prefix
  );
  @include select-theme.theme-styles($theme, $resolvers: $resolvers);

  @if map.get($theme, text-field-container-height) {
    @include select-theme.filled-height(
      map.get($theme, text-field-container-height)
    );
  }
  @if map.get($theme, text-field-container-shape) {
    @include select-theme.filled-shape-radius(
      map.get($theme, text-field-container-shape)
    );
  }
}
